/* 检查变位词： 相同字母的重新排列 */
#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>
void read_word(int counts[26]);
bool equal_array(int counts[26], int counts2[26]);
int main(void)
{
    int counts[26] = {0}, counts2[26] = {0};
    printf("Enter first word: ");
    read_word(counts);
    printf("Enter second word: ");
    read_word(counts2);
    printf("The words are%s anagrams.\n", equal_array(counts, counts2) ? "" : " not");
    return 0;
}
void read_word(int counts[26]) {
    char ch;
    while ((ch = getchar()) != '\n') {
        if (isalnum(ch))
            counts[tolower(ch) - 'a']++;
    }
}
bool equal_array(int counts[26], int counts2[26]) {
    for (int i = 0; i < 26; i++) {
        if (counts[i] != counts2[i]) 
            return false;
    }
    return true;
}